package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "leo";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        TextView tv_one = findViewById(R.id.tv_one);
//        tv_one.setText("Leo");

        Button btn = findViewById(R.id.btn);

        //Button的点击事件
//        btn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Log.e(TAG, "onClick ");
//
//            }
//        });

        // Button的长按事件
        btn.setOnLongClickListener(new OnLongClickListener(){
            @Override
            public boolean onLongClick(View view) {
                Log.e(TAG, "onLongClick: ");
                return false;
            }
        });

        //
        btn.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                Log.e(TAG, "onTouch: " + motionEvent.getAction());
                return false;
            }
        });

    }

    public void leoClick(View view) {
        Log.e(TAG, "leoClick");
    }
}